import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      component: () => import('@/layouts/DefaultLayout.vue'),
      children: [
        {
          path: '',
          name: 'Home',
          component: () => import('@/views/Home.vue')
        },
        {
          path: 'courses',
          name: 'CourseList',
          component: () => import('@/views/courses/CourseList.vue')
        },
        {
          path: 'courses/:id',
          name: 'CourseDetail',
          component: () => import('@/views/courses/CourseDetail.vue')
        },
        {
          path: 'courses/:courseId/qa',
          name: 'CourseQA',
          component: () => import('@/views/courses/QASession.vue'),
          meta: {
            requiresAuth: true
          }
        },
        {
          path: 'teacher',
          component: () => import('@/views/teacher/TeacherLayout.vue'),
          children: [
            {
              path: 'courses',
              name: 'TeacherCourses',
              component: () => import('@/views/teacher/CourseManagement.vue')
            },
            {
              path: 'assignments',
              name: 'AssignmentManagement',
              component: () => import('@/views/teacher/AssignmentManagement.vue')
            },
            {
              path: 'assignments/:assignmentId/grade',
              name: 'AssignmentGrading',
              component: () => import('@/views/teacher/AssignmentGrading.vue')
            },
            {
              path: 'assignments/submissions',
              name: 'SubmissionsList',
              component: () => import('@/views/teacher/SubmissionsList.vue')
            }
          ]
        },
        {
          path: 'student',
          component: () => import('@/views/student/StudentLayout.vue'),
          children: [
            {
              path: 'my-courses',
              name: 'MyCourses',
              component: () => import('@/views/student/MyCourses.vue')
            },
            {
              path: 'assignments',
              name: 'MyAssignments',
              component: () => import('@/views/student/MyAssignments.vue')
            },
            {
              path: 'assignments/:assignmentId/submit',
              name: 'AssignmentSubmission',
              component: () => import('@/views/student/AssignmentSubmission.vue')
            },
            {
              path: 'assignments/history',
              name: 'SubmissionHistory',
              component: () => import('@/views/student/SubmissionHistory.vue')
            }
          ]
        }
      ]
    }
  ]
})

export default router

